<!DOCTYPE html>
<html lang="zh-CN" data-theme="light">

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width,initial-scale=1" />
  <meta name="generator" content="VuePress 2.0.0-beta.51" />
  <meta name="theme" content="VuePress Theme Hope" />
  <meta property="og:url" content="https://pro.autojs.org/docs/zh/v8/crypto.html">
  <meta property="og:site_name" content="Auto.js Pro文档">
  <meta property="og:title" content="crypto - 加解密与消息摘要">
  <meta property="og:type" content="article">
  <meta property="og:updated_time" content="2022-10-22T13:39:02.000Z">
  <meta property="og:locale" content="zh-CN">
  <meta property="og:locale:alternate" content="en-US">
  <meta property="article:modified_time" content="2022-10-22T13:39:02.000Z">
  <link rel="alternate" hreflang="en-us" href="https://pro.autojs.org/docs/en/zh/v8/crypto.html">
  <link rel="icon" href="https://pro.autojs.org/docs/favicon.ico">
  <link rel="manifest" href="https://pro.autojs.org/docs/manifest.webmanifest" crossorigin="use-credentials">
  <meta name="theme-color" content="#46bd87">
  <meta name="viewport"
    content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
  <title>crypto - 加解密与消息摘要 | Auto.js Pro文档</title>
  <meta name="description" content="支持Node.js的自动化工作流JavaScript IDE">
  <style>
    :root {
      --bg-color: #fff;
    }

    html[data-theme="dark"] {
      --bg-color: #1d2025;
    }

    html,
    body {
      background-color: var(--bg-color);
    }
  </style>
  <script>
    const userMode = localStorage.getItem("vuepress-theme-hope-scheme");
    const systemDarkMode =
      window.matchMedia &&
      window.matchMedia("(prefers-color-scheme: dark)").matches;

    if (userMode === "dark" || (userMode !== "light" && systemDarkMode)) {
      document.querySelector("html").setAttribute("data-theme", "dark");
    }
  </script>
  <link rel="stylesheet" href="../../assets/style.ae9cb182.css">
  <link rel="modulepreload" href="../../assets/app.6aa2b576.js">
  <link rel="modulepreload" href="../../assets/crypto.html.740cc25d.js">
  <link rel="modulepreload" href="../../assets/_plugin-vue_export-helper.cdc0426e.js">
  <link rel="modulepreload" href="../../assets/crypto.html.4151da1a.js">
</head>

<body>


  <!-- Copyright � 2008. Spidersoft Ltd -->
  <style>
    A.applink:hover {
      border: 2px dotted #DCE6F4;
      padding: 2px;
      background-color: #ffff00;
      color: green;
      text-decoration: none
    }

    A.applink {
      border: 2px dotted #DCE6F4;
      padding: 2px;
      color: #2F5BFF;
      background: transparent;
      text-decoration: none
    }

    A.info {
      color: #2F5BFF;
      background: transparent;
      text-decoration: none
    }

    A.info:hover {
      color: green;
      background: transparent;
      text-decoration: underline
    }
  </style>


  <div id="app"><!--[--><!--[--><!--[--><span tabindex="-1"></span><a href="#main-content"
      class="skip-link sr-only">Skip to content</a><!--]-->
    <div class="theme-container has-toc"><!--[--><!--[-->
      <header class="navbar">
        <div class="navbar-left"><button class="toggle-sidebar-button" title="Toggle Sidebar"><span
              class="icon"></span></button><!----><a href="../../docs.html" class="brand"><img class="logo"
              src="../../logo.png" alt="Auto.js Pro文档"><!----><span class="site-name hide-in-pad">Auto.js
              Pro文档</span></a><!----></div>
        <div class="navbar-center"><!---->
          <nav class="nav-links">
            <div class="nav-item hide-in-mobile"><a href="../../docs.html" class="nav-link"
                aria-label="Auto.js Pro"><span class="icon iconfont icon-home"></span>Auto.js Pro<!----></a></div>
            <div class="nav-item hide-in-mobile"><a href="../guide/guide.html" class="nav-link" aria-label="指南"><span
                  class="icon iconfont icon-creative"></span>指南<!----></a></div>
            <div class="nav-item hide-in-mobile"><a href="v8.html" class="nav-link active" aria-label="第一代API文档"><span
                  class="icon iconfont icon-note"></span>第一代API文档<!----></a></div>
            <div class="nav-item hide-in-mobile"><a href="../v9/v9.html" class="nav-link" aria-label="第二代API文档"><span
                  class="icon iconfont icon-note"></span>第二代API文档<!----></a></div>
            <div class="nav-item hide-in-mobile">
              <div class="dropdown-wrapper"><button class="dropdown-title" type="button" aria-label="官网与相关链接"><span
                    class="title"><span class="icon iconfont icon-discover"></span>官网与相关链接</span><span
                    class="arrow"></span>
                  <ul class="nav-dropdown">
                    <li class="dropdown-item"><a href="../../../pro.autojs.html" rel="noopener noreferrer"
                        target="_blank" aria-label="官网与软件下载" class="nav-link"><!---->官网与软件下载<span><svg
                            class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"
                            focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15">
                            <path fill="currentColor"
                              d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                            </path>
                            <polygon fill="currentColor"
                              points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                            </polygon>
                          </svg><span class="external-link-icon-sr-only">open in new window</span></span><!----></a>
                    </li>
                    <li class="dropdown-item"><a href="https://blog.autojs.org/" rel="noopener noreferrer"
                        target="_blank" aria-label="官方博客" class="nav-link"><!---->官方博客<span><svg
                            class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"
                            focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15">
                            <path fill="currentColor"
                              d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                            </path>
                            <polygon fill="currentColor"
                              points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                            </polygon>
                          </svg><span class="external-link-icon-sr-only">open in new window</span></span><!----></a>
                    </li>
                    <li class="dropdown-item"><a href="https://pd.qq.com/s/gosos5" rel="noopener noreferrer"
                        target="_blank" aria-label="官方频道" class="nav-link"><!---->官方频道<span><svg
                            class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"
                            focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15">
                            <path fill="currentColor"
                              d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                            </path>
                            <polygon fill="currentColor"
                              points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                            </polygon>
                          </svg><span class="external-link-icon-sr-only">open in new window</span></span><!----></a>
                    </li>
                  </ul>
                </button></div>
            </div>
          </nav><!---->
        </div>
        <div class="navbar-right"><!---->
          <div class="nav-item">
            <div class="dropdown-wrapper i18n-dropdown"><button class="dropdown-title" type="button"
                aria-label="选择语言"><!--[--><svg xmlns="http://www.w3.org/2000/svg" class="icon i18n-icon"
                  viewBox="0 0 1024 1024" fill="currentColor" aria-label="i18n icon"
                  style="width:1rem;height:1rem;vertical-align:middle;">
                  <path
                    d="M379.392 460.8 494.08 575.488l-42.496 102.4L307.2 532.48 138.24 701.44l-71.68-72.704L234.496 460.8l-45.056-45.056c-27.136-27.136-51.2-66.56-66.56-108.544h112.64c7.68 14.336 16.896 27.136 26.112 35.84l45.568 46.08 45.056-45.056C382.976 312.32 409.6 247.808 409.6 204.8H0V102.4h256V0h102.4v102.4h256v102.4H512c0 70.144-37.888 161.28-87.04 210.944L378.88 460.8zM576 870.4 512 1024H409.6l256-614.4H768l256 614.4H921.6l-64-153.6H576zM618.496 768h196.608L716.8 532.48 618.496 768z">
                  </path>
                </svg><!--]--><span class="arrow"></span>
                <ul class="nav-dropdown">
                  <li class="dropdown-item"><a href="../../en/en.html" class="nav-link"
                      aria-label="English"><!---->English<!----></a></li>
                  <li class="dropdown-item"><a aria-current="page" href="crypto.html"
                      class="router-link-active router-link-exact-active nav-link active"
                      aria-label="简体中文"><!---->简体中文<!----></a></li>
                </ul>
              </button></div>
          </div><!---->
          <div class="nav-item hide-in-mobile"><button id="appearance-switch"><svg xmlns="http://www.w3.org/2000/svg"
                class="icon auto-icon" viewBox="0 0 1024 1024" fill="currentColor" aria-label="auto icon"
                style="display:block;">
                <path
                  d="M512 992C246.92 992 32 777.08 32 512S246.92 32 512 32s480 214.92 480 480-214.92 480-480 480zm0-840c-198.78 0-360 161.22-360 360 0 198.84 161.22 360 360 360s360-161.16 360-360c0-198.78-161.22-360-360-360zm0 660V212c165.72 0 300 134.34 300 300 0 165.72-134.28 300-300 300z">
                </path>
              </svg><svg xmlns="http://www.w3.org/2000/svg" class="icon dark-icon" viewBox="0 0 1024 1024"
                fill="currentColor" aria-label="dark icon" style="display:none;">
                <path
                  d="M524.8 938.667h-4.267a439.893 439.893 0 0 1-313.173-134.4 446.293 446.293 0 0 1-11.093-597.334A432.213 432.213 0 0 1 366.933 90.027a42.667 42.667 0 0 1 45.227 9.386 42.667 42.667 0 0 1 10.24 42.667 358.4 358.4 0 0 0 82.773 375.893 361.387 361.387 0 0 0 376.747 82.774 42.667 42.667 0 0 1 54.187 55.04 433.493 433.493 0 0 1-99.84 154.88 438.613 438.613 0 0 1-311.467 128z">
                </path>
              </svg><svg xmlns="http://www.w3.org/2000/svg" class="icon light-icon" viewBox="0 0 1024 1024"
                fill="currentColor" aria-label="light icon" style="display:none;">
                <path
                  d="M952 552h-80a40 40 0 0 1 0-80h80a40 40 0 0 1 0 80zM801.88 280.08a41 41 0 0 1-57.96-57.96l57.96-58a41.04 41.04 0 0 1 58 58l-58 57.96zM512 752a240 240 0 1 1 0-480 240 240 0 0 1 0 480zm0-560a40 40 0 0 1-40-40V72a40 40 0 0 1 80 0v80a40 40 0 0 1-40 40zm-289.88 88.08-58-57.96a41.04 41.04 0 0 1 58-58l57.96 58a41 41 0 0 1-57.96 57.96zM192 512a40 40 0 0 1-40 40H72a40 40 0 0 1 0-80h80a40 40 0 0 1 40 40zm30.12 231.92a41 41 0 0 1 57.96 57.96l-57.96 58a41.04 41.04 0 0 1-58-58l58-57.96zM512 832a40 40 0 0 1 40 40v80a40 40 0 0 1-80 0v-80a40 40 0 0 1 40-40zm289.88-88.08 58 57.96a41.04 41.04 0 0 1-58 58l-57.96-58a41 41 0 0 1 57.96-57.96z">
                </path>
              </svg></button></div>
          <div class="search-box" role="search" data-v-f3875574><input value="" aria-label="Search" class=""
              placeholder="Search" autocomplete="off" spellcheck="false" data-v-f3875574><!----></div><!----><button
            class="toggle-navbar-button" aria-label="Toggle Navbar" aria-expanded="false"
            aria-controls="nav-screen"><span class="button-container"><span class="button-top"></span><span
                class="button-middle"></span><span class="button-bottom"></span></span></button>
        </div>
      </header><!----><!--]--><!---->
      <div class="toggle-sidebar-wrapper"><span class="arrow left"></span></div>
      <aside class="sidebar"><!--[--><!----><!--]-->
        <ul class="sidebar-links">
          <li>
            <section class="sidebar-group">
              <p class="sidebar-heading"><!----><span class="title">指南</span><!----></p>
              <ul class="sidebar-links">
                <li><!--[--><a href="v8.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="阅读须知"><!---->阅读须知<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
              </ul>
            </section>
          </li>
          <li>
            <section class="sidebar-group">
              <p class="sidebar-heading"><!----><span class="title">API文档</span><!----></p>
              <ul class="sidebar-links">
                <li>
                  <section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span
                        class="title">自动化 -
                        控件操作</span><span class="arrow down"></span></button>
                    <ul class="sidebar-links">
                      <li><!--[--><a href="./automator/"
                          class="router-link-active router-link-exact-active nav-link sidebar-link sidebar-page"
                          aria-label="入门介绍" aria-current="page"><!---->入门介绍<!----></a>
                        <ul class="sidebar-sub-headers"></ul><!--]-->
                      </li>
                      <li><!--[--><a href="./automator/selector.html" class="nav-link sidebar-link sidebar-page"
                          aria-label="选择器"><!---->选择器<!----></a>
                        <ul class="sidebar-sub-headers"></ul><!--]-->
                      </li>
                      <li><!--[--><a href="./automator/uiobject.html" class="nav-link sidebar-link sidebar-page"
                          aria-label="控件和控件集合"><!---->控件和控件集合<!----></a>
                        <ul class="sidebar-sub-headers"></ul><!--]-->
                      </li>
                      <li><!--[--><a href="./automator/api.html" class="nav-link sidebar-link sidebar-page"
                          aria-label="automator与其他函数"><!---->automator与其他函数<!----></a>
                        <ul class="sidebar-sub-headers"></ul><!--]-->
                      </li>
                    </ul>
                  </section>
                </li>
                <li><!--[--><a href="./coordinatesBasedAutomation.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="自动化 - 坐标操作"><!---->自动化 -
                    坐标操作<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./app.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="app - 应用"><!---->app -
                    应用<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./base64.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="base64"><!---->base64<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./colors.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="colors - 颜色"><!---->colors - 颜色<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./canvas.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="canvas - 画布"><!---->canvas - 画布<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./console.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="console - 控制台"><!---->console - 控制台<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./crypto.html" class="nav-link sidebar-link sidebar-page active"
                    aria-label="crypto - 加解密与消息摘要"><!---->crypto - 加解密与消息摘要<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./debug.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="debug - 调试工具"><!---->debug - 调试工具<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./device.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="device - 设备"><!---->device - 设备<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./dialogs.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="dialogs - 对话框"><!---->dialogs - 对话框<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./engines.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="engines - 脚本引擎"><!---->engines - 脚本引擎<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./events.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="events - 事件与监听"><!---->events - 事件与监听<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./floaty.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="floaty - 悬浮窗"><!---->floaty - 悬浮窗<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./files.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="files - 文件系统"><!---->files - 文件系统<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./globals.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="globals - 全局变量与函数"><!---->globals - 全局变量与函数<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./http.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="http - HTTP网络请求"><!---->http - HTTP网络请求<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./images.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="images - 图片处理"><!---->images - 图片处理<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./keys.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="keys - 按键模拟"><!---->keys
                    - 按键模拟<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./media.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="media - 多媒体"><!---->media
                    - 多媒体<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./modules.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="module - 模块"><!---->module - 模块<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./ocr.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="ocr - 文字识别"><!---->ocr -
                    文字识别<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./plugins.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="plugins - 插件"><!---->plugins - 插件<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./powerManager.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="power_manager - 电源管理"><!---->power_manager - 电源管理<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./sensors.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="sensors - 传感器"><!---->sensors - 传感器<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./shell.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="shell - Shell命令"><!---->shell - Shell命令<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./storages.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="storages - 本地存储"><!---->storages - 本地存储<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./settings.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="settings - 设置"><!---->settings - 设置<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./threads.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="threads - 多线程"><!---->threads - 多线程<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./timers.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="timers - 定时器"><!---->timers - 定时器<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./timedTasks.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="work_manager - 定时与任务"><!---->work_manager - 定时与任务<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li>
                  <section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span
                        class="title">ui - 用户界面</span><span class="arrow down"></span></button>
                    <ul class="sidebar-links">
                      <li><a href="/docs/zh/v8/ui/ui.html" class="nav-link sidebar-link sidebar-page"
                          aria-label="ui入门介绍"><!---->ui入门介绍<!----></a>
                        <ul class="sidebar-sub-headers"></ul>
                      </li>
                      <li><a href="/docs/zh/v8/ui/basic.html" class="nav-link sidebar-link sidebar-page"
                          aria-label="基础布局与控件"><!---->基础布局与控件<!----></a>
                        <ul class="sidebar-sub-headers"></ul>
                      </li>
                      <li><a href="/docs/zh/v8/ui/advanced.html" class="nav-link sidebar-link sidebar-page"
                          aria-label="其他布局与控件"><!---->其他布局与控件<!----></a>
                        <ul class="sidebar-sub-headers"></ul>
                      </li>
                      <li><a href="/docs/zh/v8/ui/api.html" class="nav-link sidebar-link sidebar-page"
                          aria-label="api文档"><!---->api文档<!----></a>
                        <ul class="sidebar-sub-headers"></ul>
                      </li>
                      <li><a href="/docs/zh/v8/ui/customWidget.html" class="nav-link sidebar-link sidebar-page"
                          aria-label="自定义控件"><!---->自定义控件<!----></a>
                        <ul class="sidebar-sub-headers"></ul>
                      </li>
                      <li><a aria-current="page" href="/docs/zh/v8/ui/webview.html"
                          class="router-link-active router-link-exact-active nav-link sidebar-link sidebar-page"
                          aria-label="使用Web编写界面"><!---->使用Web编写界面<!----></a>
                        <ul class="sidebar-sub-headers"></ul>
                      </li>
                    </ul>
                  </section>
                </li>
                <li><!--[--><a href="./util.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="util - 工具"><!---->util -
                    工具<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./webSocket.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="WebSocket"><!---->WebSocket<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./zip.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="zip - 压缩与解压"><!---->zip -
                    压缩与解压<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
              </ul>
            </section>
          </li>
          <li>
            <section class="sidebar-group">
              <p class="sidebar-heading"><!----><span class="title">进阶</span><!----></p>
              <ul class="sidebar-links">
                <li><!--[--><a href="scriptingJava.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="和Java交互"><!---->和Java交互<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
              </ul>
            </section>
          </li>
        </ul><!--[--><!----><!--]-->
      </aside><!--[-->
      <main class="page" id="main-content"><!--[--><!---->
        <nav class="breadcrumb disable"></nav>
        <div class="page-title">
          <h1><!---->crypto - 加解密与消息摘要</h1>
          <div class="page-info"><span class="date-info" aria-label="写作日期📅" data-balloon-pos="down"><svg
                xmlns="http://www.w3.org/2000/svg" class="icon calendar-icon" viewBox="0 0 1024 1024"
                fill="currentColor" aria-label="calendar icon">
                <path
                  d="M716.4 110.137c0-18.753-14.72-33.473-33.472-33.473-18.753 0-33.473 14.72-33.473 33.473v33.473h66.993v-33.473zm-334.87 0c0-18.753-14.72-33.473-33.473-33.473s-33.52 14.72-33.52 33.473v33.473h66.993v-33.473zm468.81 33.52H716.4v100.465c0 18.753-14.72 33.473-33.472 33.473a33.145 33.145 0 01-33.473-33.473V143.657H381.53v100.465c0 18.753-14.72 33.473-33.473 33.473a33.145 33.145 0 01-33.473-33.473V143.657H180.6A134.314 134.314 0 0046.66 277.595v535.756A134.314 134.314 0 00180.6 947.289h669.74a134.36 134.36 0 00133.94-133.938V277.595a134.314 134.314 0 00-133.94-133.938zm33.473 267.877H147.126a33.145 33.145 0 01-33.473-33.473c0-18.752 14.72-33.473 33.473-33.473h736.687c18.752 0 33.472 14.72 33.472 33.473a33.145 33.145 0 01-33.472 33.473z">
                </path>
              </svg><span>2022年10月22日</span>
              <meta property="datePublished" content="2022-10-22T07:36:15.000Z">
            </span></div>
          <hr>
        </div>
        <div class="toc-place-holder">
          <aside id="toc">
            <div class="toc-header">此页内容</div>
            <div class="toc-wrapper">
              <ul class="toc-list"><!--[-->
                <li class="toc-item"><a aria-current="page"
                    href="https://pro.autojs.org/docs/zh/v8/crypto.html#crypto-digest-message-algorithm-options"
                    class="router-link-active router-link-exact-active toc-link level2">$crypto.digest(message,
                    algorithm[, options])</a></li><!----><!--]--><!--[-->
                <li class="toc-item"><a aria-current="page"
                    href="https://pro.autojs.org/docs/zh/v8/crypto.html#crypto-encrypt-data-key-algorithm-options"
                    class="router-link-active router-link-exact-active toc-link level2">$crypto.encrypt(data, key,
                    algorithm[, options])</a></li><!----><!--]--><!--[-->
                <li class="toc-item"><a aria-current="page"
                    href="https://pro.autojs.org/docs/zh/v8/crypto.html#crypto-decrypt-data-key-algorithm-options"
                    class="router-link-active router-link-exact-active toc-link level2">$crypto.decrypt(data, key,
                    algorithm[, options])</a></li><!----><!--]--><!--[-->
                <li class="toc-item"><a aria-current="page"
                    href="https://pro.autojs.org/docs/zh/v8/crypto.html#crypto-generatekeypair-algorithm-length"
                    class="router-link-active router-link-exact-active toc-link level2">$crypto.generateKeyPair(algorithm[,
                    length])</a></li><!----><!--]--><!--[-->
                <li class="toc-item"><a aria-current="page"
                    href="https://pro.autojs.org/docs/zh/v8/crypto.html#new-key-data-options"
                    class="router-link-active router-link-exact-active toc-link level2">new Key(data[, options])</a>
                </li><!----><!--]--><!--[-->
                <li class="toc-item"><a aria-current="page"
                    href="https://pro.autojs.org/docs/zh/v8/crypto.html#key-data"
                    class="router-link-active router-link-exact-active toc-link level2">Key.data</a></li>
                <!----><!--]--><!--[-->
                <li class="toc-item"><a aria-current="page"
                    href="https://pro.autojs.org/docs/zh/v8/crypto.html#new-keypair-publickey-privatekey-options"
                    class="router-link-active router-link-exact-active toc-link level2">new KeyPair(publicKey,
                    privateKey[, options])</a></li><!----><!--]--><!--[-->
                <li class="toc-item"><a aria-current="page"
                    href="https://pro.autojs.org/docs/zh/v8/crypto.html#keypair-privatekey"
                    class="router-link-active router-link-exact-active toc-link level2">KeyPair.privateKey</a></li>
                <!----><!--]--><!--[-->
                <li class="toc-item"><a aria-current="page"
                    href="https://pro.autojs.org/docs/zh/v8/crypto.html#keypair-publickey"
                    class="router-link-active router-link-exact-active toc-link level2">KeyPair.publicKey</a></li>
                <!----><!--]-->
              </ul>
            </div>
          </aside>
        </div><!---->
        <div class="theme-hope-content">
          <h1 id="crypto-加解密与消息摘要" tabindex="-1"><a class="header-anchor" href="#crypto-加解密与消息摘要"
              aria-hidden="true">#</a> crypto - 加解密与消息摘要</h1>
          <p><strong>[<a href="../../../pro.autojs.html" target="_blank" rel="noopener noreferrer">Pro 8.0.0新增<span><svg
                    class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"
                    x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15">
                    <path fill="currentColor"
                      d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                    </path>
                    <polygon fill="currentColor"
                      points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                    </polygon>
                  </svg><span class="external-link-icon-sr-only">open in new window</span></span></a>]</strong></p>
          <p>$crypto模块提供了对称加密(例如AES)、非对称加密(例如RSA)、消息摘要(例如MD5, SHA)等支持。</p>
          <h2 id="crypto-digest-message-algorithm-options" tabindex="-1"><a class="header-anchor"
              href="#crypto-digest-message-algorithm-options" aria-hidden="true">#</a> $crypto.digest(message,
            algorithm[, options])</h2>
          <ul>
            <li><code><span class="token property">data</span></code> {any} 需要进行消息摘要的消息</li>
            <li><code><span class="token property">key</span></code> {<a href="#key">Key</a>} 解密密钥</li>
            <li><code><span class="token property">algorithm</span></code> {string} 消息摘要算法，包括： <ul>
                <li><code><span class="token constant">MD5</span></code></li>
                <li>
                  <code><span class="token constant">SHA</span><span class="token operator">-</span><span class="token number">1</span></code>
                </li>
                <li>
                  <code><span class="token constant">SHA</span><span class="token operator">-</span><span class="token number">224</span></code>
                </li>
                <li>
                  <code><span class="token constant">SHA</span><span class="token operator">-</span><span class="token number">256</span></code>
                </li>
                <li>
                  <code><span class="token constant">SHA</span><span class="token operator">-</span><span class="token number">384</span></code>
                </li>
                <li>
                  <code><span class="token constant">SHA</span><span class="token operator">-</span><span class="token number">512</span></code>
                  具体可参阅 <a href="https://developer.android.com/reference/java/security/MessageDigest" target="_blank"
                    rel="noopener noreferrer">MessageDigest<span><svg class="external-link-icon"
                        xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px"
                        viewBox="0 0 100 100" width="15" height="15">
                        <path fill="currentColor"
                          d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                        </path>
                        <polygon fill="currentColor"
                          points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                        </polygon>
                      </svg><span class="external-link-icon-sr-only">open in new window</span></span></a></li>
              </ul>
            </li>
            <li><code><span class="token property">options</span></code> {Object} 可选项，用于指定<a
                href="#%E8%BE%93%E5%85%A5%E4%B8%8E%E8%BE%93%E5%87%BA%E7%9A%84%E7%B1%BB%E5%9E%8B%E4%B8%8E%E6%A0%BC%E5%BC%8F">输入与输出的类型与格式</a>
            </li>
            <li>返回 {any} 根据<code><span class="token property">options</span></code>指定的输出类型返回不同数据</li>
          </ul>
          <p>
            对数据<code><span class="token property">data</span></code>用算法<code><span class="token property">algorithm</span></code>计算消息摘要，数据<code><span class="token property">data</span></code>可以是文件、二进制、base64、hex、字符串等数据，解密后数据可以返回二进制、base64、hex、字符串或者直接写入到文件中，具体参见<a
              href="#%E8%BE%93%E5%85%A5%E4%B8%8E%E8%BE%93%E5%87%BA%E7%9A%84%E7%B1%BB%E5%9E%8B%E4%B8%8E%E6%A0%BC%E5%BC%8F">输入与输出的类型与格式</a>。
          </p>
          <div class="language-javascript ext-js line-numbers-mode">
            <pre class="language-javascript"><code><span class="token comment">// 计算字符串abc的md5</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>$crypto<span class="token punctuation">.</span><span class="token function">digest</span><span class="token punctuation">(</span><span class="token string">&quot;abc&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;MD5&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 计算字符串abc的sha-256</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>$crypto<span class="token punctuation">.</span><span class="token function">digest</span><span class="token punctuation">(</span><span class="token string">&quot;abc&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;SHA-256&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>$crypto<span class="token punctuation">.</span><span class="token function">digest</span><span class="token punctuation">(</span><span class="token string">&quot;Auto.js&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;SHA-256&quot;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token literal-property property">input</span><span class="token operator">:</span> <span class="token string">&quot;string&quot;</span><span class="token punctuation">,</span> <span class="token literal-property property">output</span><span class="token operator">:</span> <span class="token string">&quot;hex&quot;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 计算文件/sdcard/1.txt的md5</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>$crypto<span class="token punctuation">.</span><span class="token function">digest</span><span class="token punctuation">(</span><span class="token string">&quot;/sdcard/1.txt&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;MD5&quot;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
    <span class="token literal-property property">input</span><span class="token operator">:</span> <span class="token string">&quot;file&quot;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
            <div class="line-numbers" aria-hidden="true">
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
            </div>
          </div>
          <h2 id="crypto-encrypt-data-key-algorithm-options" tabindex="-1"><a class="header-anchor"
              href="#crypto-encrypt-data-key-algorithm-options" aria-hidden="true">#</a> $crypto.encrypt(data, key,
            algorithm[, options])</h2>
          <ul>
            <li><code><span class="token property">data</span></code> {any}
              明文消息，根据<code><span class="token property">options</span></code>指定的输入类型为不同格式的参数</li>
            <li><code><span class="token property">key</span></code> {<a href="#key">Key</a>}
              加密密钥。对称加密算法使用单个密钥，非对称加密则需要生成密钥对，参见<a href="#key">Key</a></li>
            <li><code><span class="token property">algorithm</span></code> {string} 加密算法，包括： <ul>
                <li>AES</li>
                <li>AES/ECB/NoPadding</li>
                <li>AES/ECB/PKCS5Padding</li>
                <li>AES/CBC/NoPadding</li>
                <li>AES/CBC/PKCS5Padding</li>
                <li>AES/CFB/NoPadding</li>
                <li>AES/CFB/PKCS5Padding</li>
                <li>AES/CTR/NoPadding</li>
                <li>AES/CTR/PKCS5Padding</li>
                <li>AES/OFB/PKCS5Padding</li>
                <li>AES/OFB/PKCS5Padding</li>
                <li>RSA/ECB/PKCS1Padding</li>
                <li>RSA/ECB/NoPadding</li>
                <li>... 具体可参阅 <a href="https://developer.android.com/reference/javax/crypto/Cipher" target="_blank"
                    rel="noopener noreferrer">javax.crypto.Cipher<span><svg class="external-link-icon"
                        xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px"
                        viewBox="0 0 100 100" width="15" height="15">
                        <path fill="currentColor"
                          d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                        </path>
                        <polygon fill="currentColor"
                          points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                        </polygon>
                      </svg><span class="external-link-icon-sr-only">open in new window</span></span></a></li>
              </ul>
            </li>
            <li><code><span class="token property">options</span></code> {Object} 可选项，用于指定<a
                href="#%E8%BE%93%E5%85%A5%E4%B8%8E%E8%BE%93%E5%87%BA%E7%9A%84%E7%B1%BB%E5%9E%8B%E4%B8%8E%E6%A0%BC%E5%BC%8F">输入与输出的类型与格式</a>
            </li>
            <li>返回 {any} 根据<code><span class="token property">options</span></code>指定的输出类型返回不同数据</li>
          </ul>
          <p>
            使用密钥<code><span class="token property">key</span></code>对数据<code><span class="token property">data</span></code>用加密算法算法<code><span class="token property">algorithm</span></code>进行加密，数据<code><span class="token property">data</span></code>可以是文件、二进制、base64、hex、字符串等数据，加密后数据可以返回二进制、base64、hex、字符串或者直接写入到文件中，具体参见<a
              href="#%E8%BE%93%E5%85%A5%E4%B8%8E%E8%BE%93%E5%87%BA%E7%9A%84%E7%B1%BB%E5%9E%8B%E4%B8%8E%E6%A0%BC%E5%BC%8F">输入与输出的类型与格式</a>。
          </p>
          <div class="language-javascript ext-js line-numbers-mode">
            <pre class="language-javascript"><code><span class="token keyword">let</span> message <span class="token operator">=</span> <span class="token string">&quot;Hello Autojs&quot;</span><span class="token punctuation">;</span>
<span class="token comment">// 密钥，由于AES等算法要求是128/192/256 bits，我们这里长度为16, 即128bits</span>
<span class="token keyword">let</span> str16 <span class="token operator">=</span> <span class="token string">&quot;a&quot;</span><span class="token punctuation">.</span><span class="token function">repeat</span><span class="token punctuation">(</span><span class="token number">16</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> key <span class="token operator">=</span> <span class="token keyword">new</span> $crypto<span class="token punctuation">.</span><span class="token function">Key</span><span class="token punctuation">(</span>str16<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// AES</span>
<span class="token function">toastLog</span><span class="token punctuation">(</span>$crypto<span class="token punctuation">.</span><span class="token function">encrypt</span><span class="token punctuation">(</span>message<span class="token punctuation">,</span> key<span class="token punctuation">,</span> <span class="token string">&quot;AES&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// [-18, 27, -69, 81, 2, -87, -116, 23, -114, -86, -111, 40, 58, -127, -29, -59]</span>
<span class="token comment">// AES输出结果用base64展示</span>
<span class="token function">toastLog</span><span class="token punctuation">(</span>
  $crypto<span class="token punctuation">.</span><span class="token function">encrypt</span><span class="token punctuation">(</span>message<span class="token punctuation">,</span> key<span class="token punctuation">,</span> <span class="token string">&quot;AES&quot;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
    <span class="token literal-property property">output</span><span class="token operator">:</span> <span class="token string">&quot;base64&quot;</span><span class="token punctuation">,</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 7hu7UQKpjBeOqpEoOoHjxQ==</span>
<span class="token comment">// AES默认明文填充模式PKCS5Padding, 结果同上</span>
<span class="token function">toastLog</span><span class="token punctuation">(</span>
  $crypto<span class="token punctuation">.</span><span class="token function">encrypt</span><span class="token punctuation">(</span>message<span class="token punctuation">,</span> key<span class="token punctuation">,</span> <span class="token string">&quot;AES/ECB/PKCS5Padding&quot;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
    <span class="token literal-property property">output</span><span class="token operator">:</span> <span class="token string">&quot;base64&quot;</span><span class="token punctuation">,</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 7hu7UQKpjBeOqpEoOoHjxQ==</span>

<span class="token comment">// AES加密</span>
<span class="token keyword">let</span> cipherText <span class="token operator">=</span> $crypto<span class="token punctuation">.</span><span class="token function">encrypt</span><span class="token punctuation">(</span>message<span class="token punctuation">,</span> key<span class="token punctuation">,</span> <span class="token string">&quot;AES&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">toastLog</span><span class="token punctuation">(</span>cipherText<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// [-18, 27, -69, 81, 2, -87, -116, 23, -114, -86, -111, 40, 58, -127, -29, -59]</span>

<span class="token comment">// RSA256KeyPair</span>
<span class="token keyword">let</span> algorithm <span class="token operator">=</span> <span class="token string">&quot;RSA&quot;</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> length <span class="token operator">=</span> <span class="token string">&quot;2048&quot;</span><span class="token punctuation">;</span>
<span class="token comment">// 生成RSA密钥对</span>
key <span class="token operator">=</span> $crypto<span class="token punctuation">.</span><span class="token function">generateKeyPair</span><span class="token punctuation">(</span>algorithm<span class="token punctuation">,</span> length<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> message <span class="token operator">=</span> <span class="token string">&quot;Hello Autojs&quot;</span><span class="token punctuation">;</span>
<span class="token comment">// RSA加密</span>
cipherText <span class="token operator">=</span> $crypto<span class="token punctuation">.</span><span class="token function">encrypt</span><span class="token punctuation">(</span>message<span class="token punctuation">,</span> key<span class="token punctuation">.</span>publicKey<span class="token punctuation">,</span> <span class="token string">&quot;RSA/ECB/PKCS1Padding&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">toastLog</span><span class="token punctuation">(</span>cipherText<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// [114, 99, -93, 6, -88, 8, -12, -53, -68, -15, ...]</span>
</code></pre>
            <div class="line-numbers" aria-hidden="true">
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
            </div>
          </div>
          <h2 id="crypto-decrypt-data-key-algorithm-options" tabindex="-1"><a class="header-anchor"
              href="#crypto-decrypt-data-key-algorithm-options" aria-hidden="true">#</a> $crypto.decrypt(data, key,
            algorithm[, options])</h2>
          <ul>
            <li><code><span class="token property">data</span></code> {any}
              密文消息<code><span class="token property">options</span></code>指定的输入类型为不同格式的参数</li>
            <li><code><span class="token property">key</span></code> {<a href="#key">Key</a>}
              解密密钥。对称加密算法使用单个密钥，非对称加密则需要生成密钥对，参见<a href="#key">Key</a></li>
            <li><code><span class="token property">algorithm</span></code> {string} 加密算法，包括： <ul>
                <li>AES</li>
                <li>AES/ECB/NoPadding</li>
                <li>AES/ECB/PKCS5Padding</li>
                <li>AES/CBC/NoPadding</li>
                <li>AES/CBC/PKCS5Padding</li>
                <li>AES/CFB/NoPadding</li>
                <li>AES/CFB/PKCS5Padding</li>
                <li>AES/CTR/NoPadding</li>
                <li>AES/CTR/PKCS5Padding</li>
                <li>AES/OFB/PKCS5Padding</li>
                <li>AES/OFB/PKCS5Padding</li>
                <li>RSA/ECB/PKCS1Padding</li>
                <li>RSA/ECB/NoPadding</li>
                <li>... 具体可参阅 <a href="https://developer.android.com/reference/javax/crypto/Cipher" target="_blank"
                    rel="noopener noreferrer">javax.crypto.Cipher<span><svg class="external-link-icon"
                        xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px"
                        viewBox="0 0 100 100" width="15" height="15">
                        <path fill="currentColor"
                          d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                        </path>
                        <polygon fill="currentColor"
                          points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                        </polygon>
                      </svg><span class="external-link-icon-sr-only">open in new window</span></span></a></li>
              </ul>
            </li>
            <li><code><span class="token property">options</span></code> {Object} 可选项，用于指定<a
                href="#%E8%BE%93%E5%85%A5%E4%B8%8E%E8%BE%93%E5%87%BA%E7%9A%84%E7%B1%BB%E5%9E%8B%E4%B8%8E%E6%A0%BC%E5%BC%8F">输入与输出的类型与格式</a>
            </li>
            <li>返回 {any} 根据<code><span class="token property">options</span></code>指定的输出类型返回不同数据</li>
          </ul>
          <p>
            使用密钥<code><span class="token property">key</span></code>对数据<code><span class="token property">data</span></code>用解密算法算法<code><span class="token property">algorithm</span></code>进行解密，数据<code><span class="token property">data</span></code>可以是文件、二进制、base64、hex、字符串等数据，解密后数据可以返回二进制、base64、hex、字符串或者直接写入到文件中，具体参见<a
              href="#%E8%BE%93%E5%85%A5%E4%B8%8E%E8%BE%93%E5%87%BA%E7%9A%84%E7%B1%BB%E5%9E%8B%E4%B8%8E%E6%A0%BC%E5%BC%8F">输入与输出的类型与格式</a>。
          </p>
          <div class="language-javascript ext-js line-numbers-mode">
            <pre class="language-javascript"><code><span class="token comment">// AES加密，加密为base64数据</span>
<span class="token keyword">let</span> key <span class="token operator">=</span> <span class="token keyword">new</span> $crypto<span class="token punctuation">.</span><span class="token function">Key</span><span class="token punctuation">(</span><span class="token string">&quot;1234567890123456&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> cipherText <span class="token operator">=</span> $crypto<span class="token punctuation">.</span><span class="token function">encrypt</span><span class="token punctuation">(</span><span class="token string">&quot;Hello, Auto.js Pro!&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;AES&quot;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
  <span class="token literal-property property">input</span><span class="token operator">:</span> <span class="token string">&quot;string&quot;</span><span class="token punctuation">,</span>
  <span class="token string-property property">&quot;output&quot;</span><span class="token operator">:</span> <span class="token string">&quot;base64&quot;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// AES解密，将base64数据解密为字符串</span>
<span class="token keyword">let</span> plaintext <span class="token operator">=</span> $crypto<span class="token punctuation">.</span><span class="token function">decrypt</span><span class="token punctuation">(</span>cipherText<span class="token punctuation">,</span> key<span class="token punctuation">,</span> <span class="token string">&quot;AES&quot;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
  <span class="token string-property property">&quot;input&quot;</span><span class="token operator">:</span> <span class="token string">&quot;base64&quot;</span><span class="token punctuation">,</span>
  <span class="token string-property property">&quot;output&quot;</span><span class="token operator">:</span> <span class="token string">&quot;string&quot;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">toastLog</span><span class="token punctuation">(</span>plaintext<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
            <div class="line-numbers" aria-hidden="true">
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
            </div>
          </div>
          <h2 id="crypto-generatekeypair-algorithm-length" tabindex="-1"><a class="header-anchor"
              href="#crypto-generatekeypair-algorithm-length" aria-hidden="true">#</a>
            $crypto.generateKeyPair(algorithm[, length])</h2>
          <ul>
            <li><code><span class="token property">algorithm</span></code> {string} 加密算法，包括 <ul>
                <li><code><span class="token constant">DH</span></code></li>
                <li><code><span class="token constant">DSA</span></code></li>
                <li><code><span class="token constant">EC</span></code></li>
                <li><code><span class="token constant">RSA</span></code></li>
              </ul>
            </li>
            <li><code><span class="token property">length</span></code> {number} 密钥长度。和算法相关，例如以位数指定的模数长度。默认为256。</li>
            <li>返回 {<a href="#keypair">KeyPair</a>}</li>
          </ul>
          <p>生成一对密钥，包括公钥和私钥。例如在RSA加密算法中，我们可以用私钥加密，公钥解密做签名；或者公钥加密，私钥解密做数据加密。</p>
          <div class="language-javascript ext-js line-numbers-mode">
            <pre class="language-javascript"><code><span class="token keyword">let</span> keyPair <span class="token operator">=</span> $crypto<span class="token punctuation">.</span><span class="token function">generateKeyPair</span><span class="token punctuation">(</span><span class="token string">&quot;RSA&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;公钥为&quot;</span><span class="token punctuation">,</span> keyPair<span class="token punctuation">.</span>publicKey<span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;私钥为&quot;</span><span class="token punctuation">,</span> keyPair<span class="token punctuation">.</span>privateKey<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">// 公钥加密、私钥解密</span>
<span class="token keyword">let</span> plainText <span class="token operator">=</span> <span class="token string">&quot;Hello World&quot;</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> bytes <span class="token operator">=</span> $crypto<span class="token punctuation">.</span><span class="token function">encrypt</span><span class="token punctuation">(</span>plainText<span class="token punctuation">,</span> keyPair<span class="token punctuation">.</span>publicKey<span class="token punctuation">,</span> <span class="token string">&quot;RSA&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> decryptedText <span class="token operator">=</span> $crypto<span class="token punctuation">.</span><span class="token function">decrypt</span><span class="token punctuation">(</span>bytes<span class="token punctuation">,</span> keyPair<span class="token punctuation">.</span>privateKey<span class="token punctuation">,</span> <span class="token string">&quot;RSA&quot;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
    <span class="token literal-property property">output</span><span class="token operator">:</span> <span class="token string">&quot;string&quot;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>decryptedText<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">// 公钥解密、私钥加密</span>
<span class="token keyword">let</span> base64 <span class="token operator">=</span> $crypto<span class="token punctuation">.</span><span class="token function">encrypt</span><span class="token punctuation">(</span>plainText<span class="token punctuation">,</span> keyPair<span class="token punctuation">.</span>privateKey<span class="token punctuation">,</span> <span class="token string">&quot;RSA&quot;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
    <span class="token literal-property property">output</span><span class="token operator">:</span> <span class="token string">&quot;base64&quot;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
decryptedText <span class="token operator">=</span> $crypto<span class="token punctuation">.</span><span class="token function">decrypt</span><span class="token punctuation">(</span>base64<span class="token punctuation">,</span> keyPair<span class="token punctuation">.</span>publicKey<span class="token punctuation">,</span> <span class="token string">&quot;RSA&quot;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
    <span class="token literal-property property">input</span><span class="token operator">:</span> <span class="token string">&quot;base64&quot;</span><span class="token punctuation">,</span>
    <span class="token literal-property property">output</span><span class="token operator">:</span> <span class="token string">&quot;string&quot;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>decryptedText<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
            <div class="line-numbers" aria-hidden="true">
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
            </div>
          </div>
          <h1 id="key" tabindex="-1"><a class="header-anchor" href="#key" aria-hidden="true">#</a> Key</h1>
          <p>
            密钥对象。可以直接通过构造函数构造。比如<code><span class="token keyword">new</span> <span class="token class-name">Key</span><span class="token punctuation">(</span><span class="token string">&#39;12345678&#39;</span><span class="token punctuation">)</span></code>。
          </p>
          <h2 id="new-key-data-options" tabindex="-1"><a class="header-anchor" href="#new-key-data-options"
              aria-hidden="true">#</a> new Key(data[, options])</h2>
          <ul>
            <li><code><span class="token property">data</span></code> {any}
              密钥的内容，根据<code><span class="token property">options</span></code>选项的输入格式而定，默认为字符串格式</li>
            <li><code><span class="token property">options</span></code> {Object} 可选参数，参见<a
                href="#%E8%BE%93%E5%85%A5%E4%B8%8E%E8%BE%93%E5%87%BA%E7%9A%84%E7%B1%BB%E5%9E%8B%E4%B8%8E%E6%A0%BC%E5%BC%8F">输入与输出的类型与格式</a>
            </li>
          </ul>
          <p>构造函数，构造一个Key对象。</p>
          <div class="language-javascript ext-js line-numbers-mode">
            <pre class="language-javascript"><code><span class="token keyword">let</span> key <span class="token operator">=</span> <span class="token keyword">new</span> $crypto<span class="token punctuation">.</span><span class="token function">Key</span><span class="token punctuation">(</span><span class="token string">&#39;1234567890123456&#39;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 获取Key的二进制数据</span>
<span class="token keyword">let</span> data <span class="token operator">=</span> key<span class="token punctuation">.</span>data<span class="token punctuation">;</span>
<span class="token comment">// 转换为base64</span>
<span class="token keyword">let</span> base64 <span class="token operator">=</span> android<span class="token punctuation">.</span>util<span class="token punctuation">.</span>Base64<span class="token punctuation">.</span><span class="token function">encodeToString</span><span class="token punctuation">(</span>data<span class="token punctuation">,</span> android<span class="token punctuation">.</span>util<span class="token punctuation">.</span>Base64<span class="token punctuation">.</span><span class="token constant">NO_WRAP</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 从base64重新构造一个Key</span>
<span class="token keyword">let</span> copiedKey <span class="token operator">=</span> <span class="token keyword">new</span> $crypto<span class="token punctuation">.</span><span class="token function">Key</span><span class="token punctuation">(</span>base64<span class="token punctuation">,</span> <span class="token punctuation">{</span><span class="token literal-property property">input</span><span class="token operator">:</span> <span class="token string">&quot;base64&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>copiedKey<span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
            <div class="line-numbers" aria-hidden="true">
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
            </div>
          </div>
          <h2 id="key-data" tabindex="-1"><a class="header-anchor" href="#key-data" aria-hidden="true">#</a> Key.data
          </h2>
          <ul>
            <li>{byte[]}</li>
          </ul>
          <p>Key的二进制数据。</p>
          <h1 id="keypair" tabindex="-1"><a class="header-anchor" href="#keypair" aria-hidden="true">#</a> KeyPair</h1>
          <p>
            密钥对对象。可以通过<code>$crypto<span class="token punctuation">.</span><span class="token function">generateKeyPair</span><span class="token punctuation">(</span><span class="token punctuation">)</span></code>函数生成，也可以通过构造函数构造。
          </p>
          <h2 id="new-keypair-publickey-privatekey-options" tabindex="-1"><a class="header-anchor"
              href="#new-keypair-publickey-privatekey-options" aria-hidden="true">#</a> new KeyPair(publicKey,
            privateKey[, options])</h2>
          <p><strong>[Pro 8.7.2新增]</strong></p>
          <ul>
            <li><code><span class="token property">publicKey</span></code> {any}
              公钥的数据，根据<code><span class="token property">options</span></code>选项的输入格式而定，默认为字符串格式</li>
            <li><code><span class="token property">privateKey</span></code> {any}
              私钥的数据，根据<code><span class="token property">options</span></code>选项的输入格式而定，默认为字符串格式</li>
            <li><code><span class="token property">options</span></code> {Object} 可选参数，参见<a
                href="#%E8%BE%93%E5%85%A5%E4%B8%8E%E8%BE%93%E5%87%BA%E7%9A%84%E7%B1%BB%E5%9E%8B%E4%B8%8E%E6%A0%BC%E5%BC%8F">输入与输出的类型与格式</a>
            </li>
          </ul>
          <p>构造函数，构造一个KeyPair对象。</p>
          <div class="language-javascript ext-js line-numbers-mode">
            <pre class="language-javascript"><code><span class="token keyword">let</span> keyPair <span class="token operator">=</span> $crypto<span class="token punctuation">.</span><span class="token function">generateKeyPair</span><span class="token punctuation">(</span><span class="token string">&quot;RSA&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 获取公钥私钥的二进制数据，并转为base64</span>
<span class="token keyword">let</span> data <span class="token operator">=</span> <span class="token punctuation">{</span>
  <span class="token literal-property property">publicKey</span><span class="token operator">:</span> <span class="token function">base64Bytes</span><span class="token punctuation">(</span>keyPair<span class="token punctuation">.</span>publicKey<span class="token punctuation">.</span>data<span class="token punctuation">)</span><span class="token punctuation">,</span>
  <span class="token literal-property property">privateKey</span><span class="token operator">:</span> <span class="token function">base64Bytes</span><span class="token punctuation">(</span>keyPair<span class="token punctuation">.</span>privateKey<span class="token punctuation">.</span>data<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>

<span class="token comment">// 从base64重新构造一个Key</span>
<span class="token keyword">let</span> copiedKeyPair <span class="token operator">=</span> <span class="token keyword">new</span> $crypto<span class="token punctuation">.</span><span class="token function">KeyPair</span><span class="token punctuation">(</span>data<span class="token punctuation">.</span>publicKey<span class="token punctuation">,</span> data<span class="token punctuation">.</span>privateKey<span class="token punctuation">,</span> <span class="token punctuation">{</span><span class="token literal-property property">input</span><span class="token operator">:</span> <span class="token string">&quot;base64&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>copiedKeyPair<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">function</span> <span class="token function">base64Bytes</span><span class="token punctuation">(</span><span class="token parameter">bytes</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> android<span class="token punctuation">.</span>util<span class="token punctuation">.</span>Base64<span class="token punctuation">.</span><span class="token function">encodeToString</span><span class="token punctuation">(</span>bytes<span class="token punctuation">,</span> android<span class="token punctuation">.</span>util<span class="token punctuation">.</span>Base64<span class="token punctuation">.</span><span class="token constant">NO_WRAP</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
            <div class="line-numbers" aria-hidden="true">
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
            </div>
          </div>
          <h2 id="keypair-privatekey" tabindex="-1"><a class="header-anchor" href="#keypair-privatekey"
              aria-hidden="true">#</a> KeyPair.privateKey</h2>
          <ul>
            <li>{<a href="#key">Key</a>}</li>
          </ul>
          <p>私钥。</p>
          <h2 id="keypair-publickey" tabindex="-1"><a class="header-anchor" href="#keypair-publickey"
              aria-hidden="true">#</a> KeyPair.publicKey</h2>
          <ul>
            <li>{<a href="#key">Key</a>}</li>
          </ul>
          <p>公钥。</p>
          <h1 id="输入与输出的类型与格式" tabindex="-1"><a class="header-anchor" href="#输入与输出的类型与格式" aria-hidden="true">#</a>
            输入与输出的类型与格式</h1>
          <p><code><span class="token property">options</span></code> {object} 用于指定加解密、消息摘要时输入和输出的类型与格式。</p>
          <ul>
            <li>
              <p><code><span class="token property">input</span></code> {string}
                输入类型，用于指定加密、解密、摘要的源数据的类型。如果输入为字符串，则默认为<code><span class="token property">string</span></code>；否则默认为<code><span class="token property">bytes</span></code>。可选的值包括：
              </p>
              <ul>
                <li><code><span class="token property">string</span></code> 字符串格式的数据</li>
                <li><code><span class="token property">base64</span></code> base64格式的数据</li>
                <li><code><span class="token property">hex</span></code> base16格式的数据</li>
                <li><code><span class="token property">bytes</span></code> Java二进制字节数组</li>
                <li><code><span class="token property">file</span></code> 文件类型，将从文件读取数据进行加解密</li>
              </ul>
            </li>
            <li>
              <p><code><span class="token property">output</span></code> {string}
                输出类型，用于指定加密、解密、摘要后的数据的类型。对于加解密，默认为<code><span class="token property">bytes</span></code>；对于消息摘要，默认为<code><span class="token property">hex</span></code>。可选的值包括：
              </p>
              <ul>
                <li><code><span class="token property">string</span></code> 字符串格式的数据</li>
                <li><code><span class="token property">base64</span></code> base64格式的数据</li>
                <li><code><span class="token property">hex</span></code> base16格式的数据</li>
                <li><code><span class="token property">bytes</span></code> Java二进制字节数组</li>
                <li><code><span class="token property">file</span></code>
                  文件类型，将处理后的数据写入到文件中，必须同时制定<code><span class="token property">dest</span></code>参数</li>
              </ul>
            </li>
            <li>
              <p><code><span class="token property">dest</span></code> {string}
                输出文件路径，<code><span class="token property">output</span></code>类型为<code><span class="token property">file</span></code>时，用于指定加密、解密、摘要后输出文件的路径
              </p>
            </li>
            <li>
              <p><code><span class="token property">encoding</span></code> {string}
                编码格式，<code><span class="token property">input</span></code>类型为<code><span class="token property">string</span></code>时，用于指定输入字符串转为二进制数据所使用的字符编码；<code><span class="token property">output</span></code>类型为<code><span class="token property">string</span></code>时，用于指定输出数据转为字符串数据所使用的字符编码。默认为<code>utf<span class="token operator">-</span><span class="token number">8</span></code>
              </p>
            </li>
            <li>
              <p><code><span class="token property">iv</span></code> {string} | {bytes} 指定AES等加密的初始化向量参数，可选。Pro
                9.2.12版本新增。</p>
            </li>
          </ul>
          <div class="language-javascript ext-js line-numbers-mode">
            <pre class="language-javascript"><code><span class="token keyword">let</span> filepath <span class="token operator">=</span> files<span class="token punctuation">.</span><span class="token function">join</span><span class="token punctuation">(</span><span class="token string">&quot;./test.txt&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;1.txt&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> message <span class="token operator">=</span> <span class="token string">&quot;Hello Autojs&quot;</span><span class="token punctuation">;</span>
$files<span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span>filepath<span class="token punctuation">,</span> message<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">let</span> str16 <span class="token operator">=</span> <span class="token string">&quot;a&quot;</span><span class="token punctuation">.</span><span class="token function">repeat</span><span class="token punctuation">(</span><span class="token number">16</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> key <span class="token operator">=</span> <span class="token keyword">new</span> $crypto<span class="token punctuation">.</span><span class="token function">Key</span><span class="token punctuation">(</span>str16<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">// 创建加密前的base64内容</span>
<span class="token keyword">let</span> base64Content <span class="token operator">=</span> $base64<span class="token punctuation">.</span><span class="token function">encode</span><span class="token punctuation">(</span>key<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 加密前的hex内容</span>
<span class="token keyword">let</span> hexContent <span class="token operator">=</span> <span class="token string">&quot;48656c6c6f204175746f6a73&quot;</span><span class="token punctuation">;</span>

<span class="token comment">// 加密文件，输出格式为二进制</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>$crypto<span class="token punctuation">.</span><span class="token function">encrypt</span><span class="token punctuation">(</span>filepath<span class="token punctuation">,</span> key<span class="token punctuation">,</span> <span class="token string">&quot;AES&quot;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token literal-property property">input</span><span class="token operator">:</span> <span class="token string">&quot;file&quot;</span><span class="token punctuation">,</span> <span class="token literal-property property">output</span><span class="token operator">:</span> <span class="token string">&quot;base64&quot;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 加密文件，输出到另一个文件</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>$crypto<span class="token punctuation">.</span><span class="token function">encrypt</span><span class="token punctuation">(</span>filepath<span class="token punctuation">,</span> key<span class="token punctuation">,</span> <span class="token string">&quot;AES&quot;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token literal-property property">input</span><span class="token operator">:</span> <span class="token string">&quot;file&quot;</span><span class="token punctuation">,</span> <span class="token literal-property property">output</span><span class="token operator">:</span> <span class="token string">&quot;file&quot;</span><span class="token punctuation">,</span> <span class="token literal-property property">dest</span><span class="token operator">:</span> <span class="token string">&quot;./output.txt&quot;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 加密base64内容，输出格式为base64</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>$crypto<span class="token punctuation">.</span><span class="token function">encrypt</span><span class="token punctuation">(</span><span class="token string">&quot;SGVsbG8gQXV0b2pz&quot;</span><span class="token punctuation">,</span> key<span class="token punctuation">,</span> <span class="token string">&quot;AES&quot;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token literal-property property">input</span><span class="token operator">:</span> <span class="token string">&quot;base64&quot;</span><span class="token punctuation">,</span> <span class="token literal-property property">output</span><span class="token operator">:</span> <span class="token string">&quot;base64&quot;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 加密hex内容，输出格式为hex</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>$crypto<span class="token punctuation">.</span><span class="token function">encrypt</span><span class="token punctuation">(</span><span class="token string">&quot;48656c6c6f204175746f6a73&quot;</span><span class="token punctuation">,</span> key<span class="token punctuation">,</span> <span class="token string">&quot;AES&quot;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token literal-property property">input</span><span class="token operator">:</span> <span class="token string">&quot;hex&quot;</span><span class="token punctuation">,</span> <span class="token literal-property property">output</span><span class="token operator">:</span> <span class="token string">&quot;hex&quot;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>$crypto<span class="token punctuation">.</span><span class="token function">encrypt</span><span class="token punctuation">(</span><span class="token string">&quot;Hello Autojs&quot;</span><span class="token punctuation">,</span> key<span class="token punctuation">,</span> <span class="token string">&quot;AES&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// [-18, 27, -69, 81, 2, -87, -116, 23, -114, -86, -111, 40, 58, -127, -29, -59]</span>

<span class="token comment">// 计算文件MD5，输出为hex</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>$crypto<span class="token punctuation">.</span><span class="token function">digest</span><span class="token punctuation">(</span>filepath<span class="token punctuation">,</span> <span class="token string">&quot;MD5&quot;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token literal-property property">input</span><span class="token operator">:</span> <span class="token string">&quot;file&quot;</span><span class="token punctuation">,</span> <span class="token literal-property property">output</span><span class="token operator">:</span> <span class="token string">&quot;hex&quot;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
            <div class="line-numbers" aria-hidden="true">
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
            </div>
          </div>
        </div><!---->
        <footer class="page-meta"><!---->
          <div class="meta-item update-time"><span class="label">上次编辑于: </span><!----></div>
          <div class="meta-item contributors"><span class="label">贡献者: </span><!--[--><!--[--><span class="contributor"
              title="email: 946994919@qq.com">hyb1996</span><!--]--><!--]--></div>
        </footer>
        <nav class="page-nav"><a href="console.html" class="nav-link prev" aria-label="console - 控制台">
            <div class="hint"><span class="arrow left"></span>上一页</div>
            <div class="link"><!---->console - 控制台</div>
          </a><a href="debug.html" class="nav-link next" aria-label="debug - 调试工具">
            <div class="hint">下一页<span class="arrow right"></span></div>
            <div class="link">debug - 调试工具<!----></div>
          </a></nav><!----><!----><!--]-->
      </main><!--]--><!----><!--]-->
    </div><!--]--><!----><!----><!--]-->
  </div>
  <script type="module" src="../../assets/app.6aa2b576.js" defer></script>
</body>

</html>